package com.zhouxiaoge.模板模式;

/**
 * @author 周小哥 gqzmy@163.com 2023/3/21 17:25
 */

public abstract class HummerModel {

    // 启动
    protected abstract void start();

    // 停止
    protected abstract void end();

    // 鸣笛
    protected abstract void alarm();

    // 发动机轰鸣
    protected abstract void engineBoom();

    // 跑起来
    final void run() {
        this.start();
        this.engineBoom();
        if (isAlarm()) {
            this.alarm();
        }
        this.end();
    }

    protected boolean isAlarm() {
        return true;
    }
}
